import { message } from 'antd';
import { gdWageList,saleWageList,privateWageList,save } from './service';

const Model = {
  namespace: 'cubeWage',
  state: {
    gdWageList:[],
    saleWageList:[],
    privateWageList:[]
  },
  effects: {
    *gdWageList({ payload }, { call,put }) {
      let result=yield call(gdWageList, payload);
      if(result.code===0){
        if(result.data&&result.data.length>0){
          return result.data;
        }else{
          return [{}]
        }
      }else{
        message.error(result.message);
      }
    },
    *saleWageList({ payload }, { call ,put}) {
      let result=yield call(saleWageList, payload);
      if(result.code===0){
        if(result.data&&result.data.length>0){
          return result.data;
        }else{
          return [{}]
        }
      }else{
        message.error(result.message);
      }
    },
    *privateWageList({ payload }, { call,put }) {
      let result=yield call(privateWageList, payload);
      if(result.code===0){
        if(result.data&&result.data.length>0){
          return result.data;
        }else{
          return [{}]
        }
      }else{
        message.error(result.message);
      }
    },
    *save({ payload }, { call,put }) {
      let result=yield call(save, payload);
      if(result.code===0){
        message.success('保存成功');
      }else{
        message.error(result.message);
      }
    },
  },
  reducers: {
    common(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
export default Model;
